{extend name="admin@public/layout/popup_form"}

{block name="form"}
<input type="hidden" value="{$id}" id="id" name="row[id]" />
    <div class="layui-form-item">
        <label class="layui-form-label">父级</label>
        <div class="layui-input-block">
            <select id="pid" name="row[pid]">
                <option value="0">------请选择------</option>
                {foreach $role_list as $key=>$vo}
                <option value="{$vo.id}" {if $vo['id']==$pid}selected="selected"{/if}>{$vo.name}</option>
                {/foreach}
            </select>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">角色名 <text title="必填项" style="color:red;">*</text></label>
        <div class="layui-input-block">
            <input type="text" name="row[name]" value="{$name}" lay-verify="required" placeholder="请输入角色名" class="layui-input" lay-verType="tips">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">权限设置</label>
        <div class="layui-input-block">
            <div id="treeview">&nbsp;&nbsp;<i class="layui-icon layui-icon-loading layui-icon layui-anim layui-anim-rotate layui-anim-loop"></i></div>
            <input type="hidden" name="row[menu_ids]" id="node_list" />
        </div>
    </div>
{/block}

{block name="script"}
<script>
    const node_list = {:json_encode($node_list,JSON_UNESCAPED_UNICODE)};

    layui.use(['layTp'],function() {
        var tree = layui.laytp_tree;
        var inst1 = tree.render({
            elem: '#treeview'
            ,data: node_list
            ,showCheckbox:true
            ,accordion:true
            ,id:'auth_node'
            ,oncheck: function(obj){
                var ids = layui.layTp.facade.get_tree_checked_ids(tree.getChecked('auth_node'));
                $('#node_list').val(ids);
            }
        });

        var node_arr = JSON.parse("{$now_node_list}");
        tree.setChecked('auth_node',node_arr);
    });
</script>
{/block}